<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>家庭作业</title>
    <style>
       #a{
           width: 410px;
           height: 410px;
           padding: 20px;
           margin: 50px;
           background-color: cornflowerblue;
           border-radius: 5px;
           position: relative;
           margin-top: 200px;
       }
       .b{
           width: 100px;
           height: 100px;
           border: 1px solid cornsilk;
           line-height: 100px;
           text-align: center;
           float: left;
           font-size: 40px;
       }
       .b:hover{
           background-color: azure;
       }
    </style>
</head>
<body>
    <div id="a">
        <div class="b">1</div>
        <div class="b">2</div>
        <div class="b">3</div>
        <div class="b">4</div>
    </div>
    <script>
        var divS = document.getElementsByClassName("b")
        console.log(divS);
        divS[0].onclick = function(event){
            var text = divS[0].innerText
            console.log(text)
            text = parseInt(text)
            text *= 2
            console.log(text)
            divS[0].innerText = text
        }
        divS[1].onclick = function(event){
            var text = divS[1].innerText
            console.log(text)
            text = parseInt(text)
            text *= 2
            console.log(text)
            divS[1].innerText = text
        }
        divS[2].onclick = function(event){
            var text = divS[2].innerText
            console.log(text)
            text = parseInt(text)
            text *= 2
            console.log(text)
            divS[2].innerText = text
        }
        divS[3].onclick = function(event){
            var text = divS[3].innerText
            console.log(text)
            text = parseInt(text)
            text *= 2
            console.log(text)
            divS[3].innerText = text
        }
    </script>
</body>
</html>